local utils = require "astrocore"
return {
  {
    "nvim-treesitter/nvim-treesitter",
    optional = true,
    opts = function(_, opts)
      if opts.ensure_installed ~= "all" then
        opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, { "lua", "luap" })
      end
    end,
  },
  {
    "williamboman/mason-lspconfig.nvim",
    optional = true,
    opts = function(_, opts)
      if vim.loop.os_uname().sysname ~= "FreeBSD" then
        opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, { "lua_ls@3.7.4" })
      end
    end,
  },
  {
    "jay-babu/mason-null-ls.nvim",
    optional = true,
    opts = function(_, opts)
      if vim.loop.os_uname().sysname ~= "FreeBSD" then
        if vim.loop.os_uname().sysname == "Linux" then
          opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, { "stylua" })
          if vim.loop.os_uname().machine == "x86_64" then
            opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, { "stylua", "selene" })
          end
        elseif vim.loop.os_uname().sysname == "Darwin" then
          opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, { "stylua", "selene@0.27.1" })
        end
      end
    end,
  },
  {
    "AstroNvim/astrolsp",
    optional = true,
    opts = function(_, opts)
      if vim.loop.os_uname().sysname == "FreeBSD" then
        opts.servers = opts.servers or {}
        table.insert(opts.servers, "lua_ls")
      end
      opts.config = require("astrocore").extend_tbl(opts.config or {}, {
        lua_ls = { settings = { Lua = { hint = { enable = true, arrayIndex = "Disable" } } } },
      })
    end,
    -- opts = {
    --   config = {
    --     lua_ls = { settings = { Lua = { hint = { enable = true, arrayIndex = "Disable" } } } },
    --   },
    -- },
  },
}
